package Test01;

import java.util.Scanner;

/**
 * ClassName:
 * Package:Test01
 * Description:
 *
 * @Author 软件232班——欧阳昊淼
 * @Create 2024/4/12 17:41
 * @Version 1.8
 */
public class BalanceTest01 {
    public static void main(String[] args) {
        double balance = 0.0;
        Scanner sc = new Scanner(System.in);
        boolean flag = true;
        do {

            System.out.println("===================");
            System.out.println("--------家庭记账----");
            System.out.println("1. 收支明细");
            System.out.println("2.登记收入");
            System.out.println("3.登记支出");
            System.out.println("4.退出");
            System.out.println("请选择（1-4）");
            System.out.println("===================");


            int selection = sc.nextInt();
            switch (selection) {
                case 1:
                    System.out.println("账户剩余:" + balance);
                    break;
                case 2:
                    System.out.println("收到多少钱:");
                    double money1 = sc.nextDouble();
                    if (money1 > 0) {
                        balance += money1;
                    } else {
                        System.out.println("输入的数据有误");
                    }
                    break;
                case 3:
                    System.out.println("支出了多少钱:");
                    double money2 = sc.nextDouble();
                    if (money2 > 0 || money2 <= balance) {
                        balance -= money2;
                    } else {
                        System.out.println("输入的数据有误");
                    }

                    break;
                case 4:
                    flag = false;
                    System.out.println("感谢使用，欢迎下次使用！");
                    break;

                default:
                    System.out.println("输入非法！");

            }


        } while (flag) ;

            sc.close();
    }
}
